package com.shaoshaohuo.app.utils;

import android.content.Context;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.ScaleAnimation;

/**
 * Created by YinSF on 16/1/21.
 */
public class AnimationUtil {
    private static final float SCALE_SIZE = 1.2f;
    /**
     * 设置view强调动画效果
     */
    public static void emphasize(Context context, View v) {
        Animation animationStart = new ScaleAnimation(1f, SCALE_SIZE, 1f, SCALE_SIZE,
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        animationStart.setDuration(500);//设置动画持续时间
        Animation animationEnd = new ScaleAnimation(SCALE_SIZE, 1f, SCALE_SIZE, 1f,
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        animationEnd.setDuration(1000);//设置动画持续时间
        AnimationSet animation = new AnimationSet(false);
        animation.addAnimation(animationStart);
        animation.addAnimation(animationEnd);
        v.startAnimation(animation);
    }

    /**
     * 设置view强调动画效果
     */
    public static void emphasize(Context context, View v, int pivotXValue) {
        Animation animationStart = new ScaleAnimation(1f, SCALE_SIZE, 1f, SCALE_SIZE,
                Animation.RELATIVE_TO_SELF, pivotXValue, Animation.RELATIVE_TO_SELF, 0.5f);
        animationStart.setDuration(500);//设置动画持续时间
        Animation animationEnd = new ScaleAnimation(SCALE_SIZE, 1f, SCALE_SIZE, 1f,
                Animation.RELATIVE_TO_SELF, pivotXValue, Animation.RELATIVE_TO_SELF, 0.5f);
        animationEnd.setDuration(1000);//设置动画持续时间
        AnimationSet animation = new AnimationSet(false);
        animation.addAnimation(animationStart);
        animation.addAnimation(animationEnd);
        v.startAnimation(animation);
    }
}
